var defaultColumns = [
    {
        label: '标的名称',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.fullName;
        }
    },
    {
        label: '标的编号',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return '<a href="javascript:loanInfo(\'' + data.loan.loanId + '\')">' + data.loan.loanNumber + '</a>';
        }
    },
    {
        label: '借款人名称',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return '<a href="javascript:userInfo(\'' + data.loan.userId + "','" + data.loan.userName + '\')">' + data.loan.userName + '</a>';
        }
    },
    {
        label: '借款金额',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            var loanAmountD = data.loan.loanAmountD;
            return loanAmountD + "元";
        }
    },
    {
        label: '已借款金额',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.currentAmountD + "元";
        }
    },
    {
        label: '完成比例',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.currentAmountD / data.loan.loanAmountD * 100 + "%";
        }
    },
    {
        label: '融资期限',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.allottedTime + "天";
        }
    },
    {
        label: '年利率',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.rateD + "%";
        }
    },
    {
        label: '借款期限',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.loanTime + "天";
        }
    },
    {
        label: '状态',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            return data.loan.loanStatusStr;
        }
    },
    {
        label: '创建时间',
        align: 'center',
        render: function (value, data) {
            if (data.loan === undefined) {
                return '';
            }
            var date = new Date(data.loan.addDate);
            return date.Format("yyyy年MM月dd日");
        }
    }
];

function loanInfo(loanId) {
    BJUI.dialog({
        id: 'loanInfo' + loanId,
        url: '/admin/loan/loan/info?loanId=' + loanId,
        title: '标的' + loanId + '的详情',
        width: 1200,
        height: 1200 * 0.618
    })
}

function userInfo(id, userName) {
    BJUI.dialog({
        id: 'userInfo_' + id,
        url: '/admin/user/userInfo?id=' + id,
        title: '' + userName + '用户信息',
        width: 1200,
        height: 1200 * 0.618
    });
}